GtkPadController: Notify actions back to the windowing on wayland
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 4 Aug 2016 17:49:27 +0000 (19:49 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 23 Aug 2016 19:01:45 +0000 (21:01 +0200)
This allows applications to provide descriptions of the actions performed
by each pad feature. pass the GtkPadActionEntry labels for this.

https://bugzilla.gnome.org/show_bug.cgi?id=770026

gtk/gtkpadcontroller.c

index dd91835f867c397a0c7ae29929b77f77a1464e56..df54d5d49ea02ad45e3c827d3892b16ce55530c0 100644 (file)
@@ -160,6 +160,36 @@ gtk_pad_controller_handle_mode_switch (GtkPadController *controller,
                                        guint             group,
                                        guint             mode)
 {
+#ifdef GDK_WINDOWING_WAYLAND
+  if (GDK_IS_WAYLAND_DISPLAY (gdk_device_get_display (pad)))
+    {
+      const GtkPadActionEntry *entry;
+      gint elem, idx, n_features;
+
+      for (elem = GTK_PAD_ACTION_BUTTON; elem <= GTK_PAD_ACTION_STRIP; elem++)
+        {
+          n_features = gdk_device_pad_get_n_features (GDK_DEVICE_PAD (pad),
+                                                      elem);
+
+          for (idx = 0; idx < n_features; idx++)
+            {
+              if (gdk_device_pad_get_feature_group (GDK_DEVICE_PAD (pad),
+                                                    elem, idx) != group)
+                continue;
+
+              entry = gtk_pad_action_find_match (controller, elem, idx, mode);
+              if (!entry)
+                continue;
+              if (!g_action_group_has_action (controller->action_group,
+                                              entry->action_name))
+                continue;
+
+              gdk_wayland_device_pad_set_feedback (pad, elem, idx,
+                                                   g_dgettext (NULL, entry->label));
+            }
+        }
+    }
+#endif
 }
 
 static gboolean